<?php
defined('_XR_EXEC') or die();
/**
* 变量缓存类
*
*  by zhoupeng 2011-7-18
*/
class R{
	var $gets;
	var $posts;
	var $data = array (); //要生成到页面的变量缓存
	var $arr=array();
	
	
	var $view_display=true;
	var $view_default;
	var $view_direc;
	
	
	public static function &singleton(){
		static $instance;
		if(!isset($instance)){
			$instance=new R();
		}
		return $instance;
	}
	public function get($k='',$defaults=NULL){
		if($k == ''){
			return $this->arr;
		}else{
			$p = $this->arr;
			$name = explode('.',$k);
			foreach ($name as $_name){
				if(!is_array($p) || !isset($p[$_name])){
					return $defaults;
				}
				$p = $p[$_name];
			}
			return $p;
		}
	}
	public function set($k,$v){
    $p = &$this->arr;
		$name = explode('.',$k);
		foreach ($name as $_name){
			if(!is_array($p)){
				$p=array();
			}
			$p = &$p[$_name];
		}
		return $p = $v;
	}
}	 
?>